from sqlalchemy import Column, Integer, String, DateTime
from base import Base
from sqlalchemy.sql import func


class User(Base):
    __tablename__ = "users"
    id = Column(Integer, primary_key=True, index=True)
    username = Column(String(255), unique=True, index=True)
    hashed_password = Column(String(255), comment="哈希密码")
    status = Column(Integer, default=1, comment="状态 0 禁用 1 正常")
    deleted_at = Column(DateTime(timezone=True), nullable=True, comment='删除时间')
    created_at = Column(DateTime(timezone=True), server_default=func.now(), comment='创建时间')
    updated_at = Column(DateTime(timezone=True), onupdate=func.now(), comment='更新时间')

roles = Column(String(255), comment='规则')  # 简单示例，实际应用中可能需要单独的角色模型
